import Request from 'luch-request'
import {API_URL} from '@/config/ApiConfig.js'
import {
	CodeAccess,
	AuthAccess,
	ErrorAccess,
} from './middleware'

const request = new Request()

/* 设置全局配置 */
request.setConfig((config) => { 
  config.baseURL = API_URL
  config.header = {
    ...config.header,
		'Content-Type':'application/json;charset=utf-8'
  }
  return config
})

/* 请求拦截器 */
// 鉴权Token
// request.interceptors.request.use(AuthAccess.success,AuthAccess.fail)

/* 响应拦截器 */
// 响应200 Token失效502 Token缺失503
// request.interceptors.response.use(CodeAccess.success,CodeAccess.fail)
// request.interceptors.response.use(ErrorAccess.success,ErrorAccess.fail)

export default request
